let basUrl = 'https://www.900yeah.com/';
const app = getApp()

exports.code = (data, callback) => { //获取  oppenid
  console.log(data)
  wx.request({
    url: basUrl + 'api/User/login',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    data: data,
    method: 'POST',
    success: function(res) {
      callback(res)
    },
    fail: function(err) {
      callback(err)
    }

  })
}

exports.tokens = (data, callback) => { // 获取token
  // data.level = app.globalData.level
  console.log(data)
  wx.request({
    url: basUrl + 'api/User/register',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    data: data,
    method: 'POST',
    success: function(res) {
      callback(res)
    },
    fail: function(err) {
      callback(err)
    }
  })
}

exports.index = (callback) => { //  首页接口
  wx.request({
    url: basUrl + 'api/index/indexlist',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    method: 'POST',
    success: function(res) {
      callback(res)
    },
    fail: function(err) {
      callback(err)
    }
  })
}

exports.indexs = (data, callback) => { //首页传token接口

  wx.request({
    url: basUrl + 'api/index/indexlist',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    method: 'POST',
    data: data,
    success: function(res) {
      callback(res)
    },
    fail: function(err) {
      callback(err)
    }
  })
}
exports.newindexs = (data, callback) => { //首页动画
  wx.request({
    url: basUrl + 'api/index/newindexlist',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    method: 'POST',
    data: data,
    success: function(res) {
      callback(res)
    },
    fail: function(err) {
      callback(err)
    }
  })
}

exports.animation = (callback) => {
  wx.request({
    url: basUrl + 'api/Index/graph',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    method: 'POST',
    success: function(res) {
      callback(res)
    },
    fail: function(err) {
      callback(err)
    }
  })
}

exports.buyContent = (data, callback) => { // 产品详情

  wx.request({
    url: basUrl + 'api/Commodity/index',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    data: data,
    method: 'POST',
    success: function(res) {
      callback(res)
      console.log(res)
    },
    fail: function(err) {
      callback(err)
    }
  })
}
exports.newBuyContent = (data, callback) => { // 购物车列表进入产品详情
  wx.request({
    url: basUrl + 'api/Commodity/newindex',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    data: data,
    method: 'POST',
    success: function(res) {
      callback(res)
    },
    fail: function(err) {
      callback(err)
    }
  })
}

exports.shopContent = (data, callback) => { // 商品详情

  wx.request({
    url: basUrl + 'api/Shoppingcart/newindex',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    data: data,
    method: 'POST',
    success: function(res) {
      callback(res)
      console.log(res)

    },
    fail: function(err) {
      callback(err)
    }
  })
}

exports.buyBoxShow = (data, callback) => { //加入购物车展示接口
  wx.request({
    url: basUrl + 'api/Shoppingcart/newcommgetlist',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    data: data,
    method: 'POST',
    success: function(res) {
      callback(res)
    },
    fail: function(err) {
      callback(err)
    }
  })
}

exports.buyList = (data, callback) => { // 添加购物车

  wx.request({
    url: basUrl + 'api/Shoppingcart/shoppingadd',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded',
      'token': wx.getStorageSync('token')
    },

    data: data,
    method: 'POST',
    success: function(res) {
      callback(res)
    },
    fail: function(err) {
      callback(err)
    }
  })


}

exports.shoppingList = (callback) => { //购物车列表
  wx.request({
    url: basUrl + 'api/Shoppingcart/commgetlist',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded',
      'token': wx.getStorageSync('token')
    },
    method: 'POST',
    success: function(res) {
      callback(res)
    },
    fail: function(err) {
      callback(err)
    }

  })
}


exports.removeShopping = (data, callback) => { // 购物车删除
  wx.request({
    url: basUrl + 'api/Shoppingcart/commdelete',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded',
      'token': wx.getStorageSync('token')
    },
    data: data,
    method: 'POST',
    success: function(res) {
      callback(res)
    },
    fail: function(err) {
      callback(err)
    }

  })
}


exports.stateShopping = (data, callback) => { //购物车 +-

  wx.request({
    url: basUrl + 'api/Shoppingcart/shoppupdate',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded',
      'token': wx.getStorageSync('token')
    },
    data: data,
    method: 'POST',
    success: function(res) {
      callback(res)
    },
    fail: function(err) {
      callback(err)
    }
  })

}

exports.payBuy = (data, callback) => {

  wx.request({
    url: basUrl + 'api/Order/payorder',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded',
      'token': wx.getStorageSync('token')
    },
    method: 'POST',
    data: data,
    success: function(res) {
      callback(res)
    },
    fail: function(err) {
      callback(err)
    }
  })

}

exports.payOrder = (lists, callback) => { //订单确认
  console.log(lists)
  let nesList = {
    list: lists
  }
  wx.request({
    url: basUrl + `api/Order/payorder`,
    header: {
      'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8',
      'token': wx.getStorageSync('token')
    },
    method: 'POST',
    data: nesList,
    success: function(res) {
      callback(res)
    },
    fail: function(err) {
      callback(err)
    }
  })
}

exports.pay = (data, callback) => { // 支付接口
  // let nesList = {
  //   list: data
  // }
  console.log(data)
  wx.request({
    url: basUrl + 'api/Order/newindex',
    header: {
      'Content-Type': 'application/json ', //application/json 
      'token': wx.getStorageSync('token')
    },
    data: data,
    method: 'POST',
    success: function(res) {
      callback(res)

    },
    fail: function(err) {
      callback(err)
    }

  })

}


exports.payGo = (data, callback) => { // 订单列表支付接口
  console.log(data)
  wx.request({
    url: basUrl + 'api/Order/index',
    header: {
      'Content-Type': 'application/json ', //application/json 
      'token': wx.getStorageSync('token')
    },
    data: data,
    method: 'POST',
    success: function(res) {
      callback(res)
    },
    fail: function(err) {
      callback(err)
    },

  })

}

exports.address = (data, callback) => { // 添加地址接口
  wx.request({
    url: basUrl + 'api/User/regionadd',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded ', //application/json 
      'token': wx.getStorageSync('token')
    },
    data: data,
    method: 'POST',
    success: function(res) {
      callback(res)

    },
    fail: function(err) {
      callback(err)
    }
  })

}



exports.upData = (data, callback) => {

  wx.request({
    url: basUrl + 'api/User/regionaupdate',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded ', //application/json 
      'token': wx.getStorageSync('token')
    },
    data: data,
    method: 'POST',
    success: function(res) {
      callback(res)

    },
    fail: function(err) {
      callback(err)
    }
  })


}

exports.siteList = (callback) => { //  地址列表
  wx.request({
    url: basUrl + 'api/User/regionindex',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded ', //application/json 
      'token': wx.getStorageSync('token')
    },
    method: 'POST',
    success: function(res) {
      callback(res)
    },
    fail: function(err) {
      callback(err)
    }
  })

}

exports.siteRemove = (data, callback) => { // 删除地址

  wx.request({
    url: basUrl + 'api/User/userredelete',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded ', //application/json 
      'token': wx.getStorageSync('token')
    },
    data: data,
    method: 'POST',
    success: function(res) {
      callback(res)
    },
    fail: function(err) {
      callback(err)
    }
  })

}

exports.siteModify = (data, callback) => {

  wx.request({
    url: basUrl + 'api/User/cateSave',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded ', //application/json 
      'token': wx.getStorageSync('token')
    },
    data: data,
    method: 'POST',
    success: function(res) {
      callback(res)
    },
    fail: function(err) {
      callback(err)
    }
  })

}

exports.My = (callback) => { //我的接口
  wx.request({
    url: basUrl + 'api/user/userindex',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded ', //application/json 
      'token': wx.getStorageSync('token')
    },
    method: 'POST',
    success: function(res) {
      callback(res)
    },
    fail: function(err) {
      callback(err)
    }
  })
}


exports.orderList = (data, callback) => { //订单列表
  console.log(data)
  wx.request({
    url: basUrl + 'api/User/newdetails',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded ', //application/json 
      'token': wx.getStorageSync('token')
    },
    data: data,
    method: 'POST',
    success: function(res) {
      callback(res)
    },
    fail: function(err) {
      callback(err)
    }

  })

}


exports.orderConten = (data, callback) => { //订单详情

  wx.request({
    url: basUrl + 'api/User/orderindex',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded ', //application/json 
      'token': wx.getStorageSync('token')
    },
    data: data,
    method: 'POST',
    success: function(res) {
      callback(res)
    },
    fail: function(err) {
      callback(err)
    }

  })
}


exports.logistics = (data, callback) => { //查询物流信息

  wx.request({
    url: basUrl + 'api/User/logistics',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded ', //application/json 
      'token': wx.getStorageSync('token')
    },
    data: data,
    method: 'POST',
    success: function(res) {
      callback(res)
    },
    fail: function(err) {
      callback(err)
    }

  })

}


exports.confirmarrival = (data, callback) => { //确认订单

  wx.request({
    url: basUrl + 'api/order/confirmarrival',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded ', //application/json 
      'token': wx.getStorageSync('token')
    },
    data: data,
    method: 'POST',
    success: function(res) {
      callback(res)
    },
    fail: function(err) {
      callback(err)
    }

  })

}

exports.selet = (data, callback) => { // 地址选中

  wx.request({
    url: basUrl + 'api/User/choice',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded ', //application/json 
      'token': wx.getStorageSync('token')
    },
    data: data,
    method: 'POST',
    success: function(res) {
      callback(res)
    },
    fail: function(err) {
      callback(err)
    }

  })
}
exports.xiangqing = (data, callback) => { //  全部商品详情

  wx.request({
    url: basUrl + 'api/Commodity/productlist',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded ', //application/json 
      'token': wx.getStorageSync('token')
    },
    data: data,
    method: 'POST',
    success: function(res) {
      callback(res)
    },
    fail: function(err) {
      callback(err)
    }

  })
}
exports.gushi = (data, callback) => { //  故事

  wx.request({
    url: basUrl + 'api/Story/index',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded ', //application/json 
      'token': wx.getStorageSync('token')
    },
    data: data,
    method: 'POST',
    success: function(res) {
      callback(res)
    },
    fail: function(err) {
      callback(err)
    }

  })
}
exports.gouwuche = (data, callback) => { // 新加入购物车
  console.log(data,'新的加入购物车接口')
  wx.request({
    url: basUrl + 'api/Shoppingcart/shopindex',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded ', 
      'token': wx.getStorageSync('token')
    },
    data: data,
    method: 'POST',
    success: function (res) {
      callback(res)
    },
    fail: function (err) {
      callback(err)
    }
  })
}
// --------------------------------
exports.newregister = (data, callback) => { // 新人领取授权
  console.log(data, '新人领取授权')
  var newlist = {
    list:data
  }
  wx.request({
    url: basUrl + 'api/User/newregister',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded ',
      'token': wx.getStorageSync('token')
    },
    data: newlist,
    method: 'POST',
    success: function (res) {
      callback(res)
    },
    fail: function (err) {
      callback(err)
    }
  })
}

exports.coupon = (data, callback) => { // 首页优惠券显示
  console.log(data, '首页优惠券显示')
  wx.request({
    url: basUrl + 'api/Index/coupon',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded ',
      'token': wx.getStorageSync('token')
    },
    data: data,
    method: 'POST',
    success: function (res) {
      callback(res)
    },
    fail: function (err) {
      callback(err)
    }
  })
}
exports.newuserindex = (data, callback) => { // 我的
  console.log('我的')
  wx.request({
    url: basUrl + 'api/user/newuserindex',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded ',
      'token': wx.getStorageSync('token')
    },
    data: data,
    method: 'POST',
    success: function (res) {
      callback(res)
    },
    fail: function (err) {
      callback(err)
    }
  })
}
exports.mylogistics = (data, callback) => { // 物流弹框
  console.log(data, '物流弹框')
  wx.request({
    url: basUrl + 'api/user/mylogistics',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded ',
      'token': wx.getStorageSync('token')
    },
    data: data,
    method: 'POST',
    success: function (res) {
      callback(res)
    },
    fail: function (err) {
      callback(err)
    }
  })
}
exports.mydiscount = (data, callback) => { // 我的优惠券
  console.log(data,'我的优惠券')
  wx.request({
    url: basUrl + 'api/user/mydiscount',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded ',
      'token': wx.getStorageSync('token')
    },
    data: data,
    method: 'POST',
    success: function (res) {
      callback(res)
    },
    fail: function (err) {
      callback(err)
    }
  })
}
exports.friendTrading = (data, callback) => { // 我的好友列表
  console.log(data, '我的好友列表')
  wx.request({
    url: basUrl + 'api/user/friendTrading',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded ',
      'token': wx.getStorageSync('token')
    },
    data: data,
    method: 'POST',
    success: function (res) {
      callback(res)
    },
    fail: function (err) {
      callback(err)
    }
  })
}
exports.user_card = (data, callback) => { // 我的邀请卡
  console.log(data, '我的邀请卡')
  wx.request({
    url: basUrl + 'api/user/user_card',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded ',
      'token': wx.getStorageSync('token')
    },
    data: data,
    method: 'POST',
    success: function (res) {
      callback(res)
    },
    fail: function (err) {
      callback(err)
    }
  })
}
exports.newpayorder = (lists, callback) => { // 支付订单
  console.log(lists, '支付订单')
  let nesList = {
    list: lists
  }
  wx.request({
    url: basUrl + 'api/Order/newpayorder',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded ',
      'token': wx.getStorageSync('token')
    },
    data: nesList,
    method: 'POST',
    success: function (res) {
      callback(res)
    },
    fail: function (err) {
      callback(err)
    }
  })
}

exports.choosecoupon = (data, callback) => { // 支付优惠券
  console.log(data, '支付优惠券')
  wx.request({
    url: basUrl + 'api/user/choosecoupon',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded ',
      'token': wx.getStorageSync('token')
    },
    data: data,
    method: 'POST',
    success: function (res) {
      callback(res)
    },
    fail: function (err) {
      callback(err)
    }
  })
}

exports.thebalanceofmy = (data, callback) => { // 钱包余额
  console.log(data, '钱包余额')
  wx.request({
    url: basUrl + 'api/user/thebalanceofmy',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded ',
      'token': wx.getStorageSync('token')
    },
    data: data,
    method: 'POST',
    success: function (res) {
      callback(res)
    },
    fail: function (err) {
      callback(err)
    }
  })
}
exports.mydetail = (data, callback) => { // 交易明细
  console.log(data, '交易明细')
  wx.request({
    url: basUrl + 'api/user/mydetail',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded ',
      'token': wx.getStorageSync('token')
    },
    data: data,
    method: 'POST',
    success: function (res) {
      callback(res)
    },
    fail: function (err) {
      callback(err)
    }
  })
}
exports.order_cancel = (data, callback) => { // 取消订单
  console.log(data, '取消订单')
  wx.request({
    url: basUrl + 'api/user/order_cancel',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded ',
      'token': wx.getStorageSync('token')
    },
    data: data,
    method: 'POST',
    success: function (res) {
      callback(res)
    },
    fail: function (err) {
      callback(err)
    }
  })
}
exports.xin_token = (data, callback) => { // 动画判断 1新 2老
  console.log(data, '动画判断')
  wx.request({
    url: basUrl + 'api/Index/token',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded ',
    },
    data: data,
    method: 'POST',
    success: function (res) {
      callback(res)
    },
    fail: function (err) {
      callback(err)
    }
  })
}